package studentmanagement;

import java.util.ArrayList;
import java.util.List;

public class Teacher extends Person {
    // 教师特有属性：授课列表（一个教师可教多门课）
    private List<Course> teachingCourses = new ArrayList<>();

    // 子类构造方法：通过super()调用父类构造
    public Teacher(String id, String name, String gender) {
        super(id, name, gender); // 调用父类构造方法初始化共性属性
    }

    // 授课方法（完善为可教多门课）
    public void teach(Course course) {
        if (!teachingCourses.contains(course)) {
            teachingCourses.add(course);
            course.setTeacher(this); // 关联课程与教师
            System.out.println(name + "老师开始讲授《" + course.getCourseName() + "》");
        } else {
            System.out.println(name + "老师已负责《" + course.getCourseName() + "》的教学");
        }
    }

    // 打印授课列表
    public void showTeachingCourses() {
        System.out.println("\n" + name + "老师的授课列表：");
        if (teachingCourses.isEmpty()) {
            System.out.println("暂无授课安排");
            return;
        }
        for (Course course : teachingCourses) {
            System.out.println("课程ID：" + course.getId() +
                    "，课程名：" + course.getCourseName() +
                    "，时间：" + course.getTime() +
                    "，地点：" + course.getLocation() +
                    "，学生数：" + course.getCurrentStudents());
        }
    }

    // getter
    public List<Course> getTeachingCourses() {
        return teachingCourses;
    }
}